package com.shwread.android.qysw.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.shwread.android.qysw10000227.R;

import logic.constants.DefaultConsts;
import logic.util.Utils;


/**
 * 备注
 * 
 * @author xuzhijun
 * @date 2015年3月17日
 */
public class RemarkActivity
        extends
        Activity
        implements
        OnClickListener
{
	
	private TextView tvTitle;
	private Button   btnHome;
	private Button   btnBack;
	
	private EditText remarkContentEdt;
	private Button   submitBtn;
	
	private String   remarkContent;
	private Intent   intent;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.remark);
		initView();
		setListener();
		initData();
	}
	
	private void initView() {
		//Title
		tvTitle = (TextView) findViewById(R.id.common_header_name);
		tvTitle.setText(getResources().getString(R.string.remark_title));
		btnHome = (Button) findViewById(R.id.common_header_home);
		btnHome.setVisibility(View.VISIBLE);
		btnBack = (Button) findViewById(R.id.common_header_back);
		btnBack.setVisibility(View.VISIBLE);
		
		remarkContentEdt = (EditText) findViewById(R.id.remark_content_edt);
		submitBtn = (Button) findViewById(R.id.remark_submit_btn);
	}
	
	private void setListener() {
		btnHome.setOnClickListener(this);
		btnBack.setOnClickListener(this);
		submitBtn.setOnClickListener(this);
	}
	
	private void initData() {
		// TODO: 
		
		if (getIntent().getExtras() == null)
		{
			intent = new Intent();
		}
		else
		{
			intent = getIntent();
			remarkContentEdt.setText(intent.getExtras().getString(DefaultConsts.REMARK));
		}
		
	}
	
	@Override
	protected void onPause() {
		super.onPause();
	}
	
	@Override
	protected void onResume() {
		super.onResume();
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.common_header_home:
//				startActivity(new Intent(this, MainActivity.class));
				BaseSimpleActivity.gotoMainActivity();
				break;
			case R.id.common_header_back:
				RemarkActivity.this.finish();
				break;
			case R.id.remark_submit_btn:
				//TODO
				remarkContent = remarkContentEdt.getText().toString();
				if (Utils.isNotEmpty(remarkContent))
				{
					
					intent.putExtra(DefaultConsts.REMARK, remarkContent);
					Utils.ToastShow(RemarkActivity.this, remarkContent);
					this.setResult(ConfirmOrderActivity.REMARK_FROM_CODE, intent);
					this.finish();
				}
				
				break;
		
		}
		
	}
	
}
